The PowerPC processor family supports a rich variety of extended mnemonics for its three conditional branch operators: bc , bclr , and bcctr . Normally, the condition and the nature of the branch are specified by numeric operands, but with the extended mnemonics, these numeric operands are determined by the assembler from the mnemonic used.
Conditional branches can alter the contents of the Count Register ( ctr ), and can take effect based on the resulting value in the Count Register, and on whether a specified condition is true or false. The first table below summarizes the extended mnemonics for branches that affect the Count Register, while the second summarizes additional mnemonics for branches on true and false conditions that don't affect the Count Register. The effect of the branch is given on the left. The first four columns of each table are for branches where the Link Register bit in the instruction is clear (not set); the remaining columns are for branches where the Link Register bit in the instruction is set. Each set of four columns gives mnemonics for relative and absolute branches, and for branches to the Link Register or the Count Register.
Branch Type |
LR not set |
LR set |
||||||
---|---|---|---|---|---|---|---|---|
|
||||||||
The mnemonics in the table above encode specific values for the BO field of the non-extended operators. The BO field controls the effect on the Count Register and on what type of condition the branch is to be taken. The BI field, which controls the specific condition to consider, must still be given, as the first operand. The value of this operand indicates which field of the Condition Register to use, and which bit within that field to consider.
The Condition Register has 8 fields, numbered 0 to 7, each of which contains a bit for conditions less than , greater than , equal , and summary overflow or unordered . The numeric value for field n of the Condition Register is 4* n , and the numeric values for the conditions are 0, 1, 2, and 3, respectively. The following symbols may be used instead of numbers:
Symbol |
Value |
Meaning |
---|---|---|
For example, a branch if condition true for the condition greater than in Condition Register field 3 could be written in any of these ways:
bt cr3+gt,target
bt 12+1,target
bt 13,target
Omitting the symbol for either the Condition Register field or the condition is permitted, as long as the result of the expression is a number from 0-31:
bt gt,target ; uses field 0
bt cr3,target ; branches on less than in field 3
bt 13,target ; branches on less than in field 3
Another way to specify these conditions is to use the extended mnemonics in the second table, below. These mnemonics encode the actual condition on which to take a branch. The second and third letters of the mnemonic indicate that condition:
Code |
Meaning |
---|---|
Some condition codes, such as le , are actually more compact codes for a false result on the opposite condition in the set of conditions given previously (for example, le is equivalent to if condition false on condition greater than ).
By default, the extended mnemonics in the table below used Condition Register field 0. An optional first operand can be given to specify another field, in either numeric form or as a symbol of the form cr n . For example:
bgt target ; branch if cr0 shows "greater than"
bgt cr3,target ; branch if cr3 shows "greater than"
Branch Type |
LR not set |
LR set |
||||||
---|---|---|---|---|---|---|---|---|
|
bc |
bca |
bclr |
bcctr |
bcl |
bcla |
bclrl |
bcctrl |
|
Rel. |
Abs. |
to LR |
to CTR |
Rel. |
Abs. |
to LR |
to CTR |